
import { userUpload } from "@monorepo/api"
export default function Upload(){
    const formData=new FormData()
    let file=null
    function fileFn(event){
        file=event.target.files[0]
        console.log(file)
        formData.append("file", file)
        //   const formData = new FormData()
        //                 formData.append("type",type)
        //                 formData.append("imgFile", data)
    }
    function userUploadFn(){
        if(!file){
            alert("请上传图片");
            return false;
        }
        userUpload(formData).then(res=>{
            console.log(res)
        })
    }
    return (
       <>
       <input type="file" name="file" onChange={(event)=>fileFn(event)} /> 
        <button type="button" onClick={userUploadFn}>上传文件</button>
        </>
    )
}